home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
6_12.lha
/
6_12
/
6_12a.c
next >
Wrap
Text File
|
1993-08-08
|
434b
|
26 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
include <stream.h>
xtern int atoi(const char*);
/ calculate n!
nt fact(int n)
if (n < 2)
return 1;
else
return n * fact(n - 1);
/ print out n! for each of the arguments
ain(int, char**argv)
while (*++argv)
cout << *argv << "!=" <<
fact(atoi(*argv)) << "\n";
return 0;